package com.zhaopin.gitlab;

import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import org.apache.commons.lang3.ObjectUtils;

import java.io.IOException;
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;

public class BaselineExp {

    public static void main(String[] args) throws IOException {

        String filePath = "/Users/zhaopin/IdeaProjects/easyjar/dir/exp/recommend";
//        String filePath = "D:\\资料\\下载\\position";


        //线上的
        List<String> onlineList = Files.readAllLines(Paths.get(filePath + "/onlineExp.txt"), Charset.defaultCharset());

        //有用户访问的
        List<String> haveUserGetList = Files.readAllLines(Paths.get(filePath + "/rpc-position-recommend-online-exp.csv"), Charset.defaultCharset());


        //有用户访问的
        List<String> baseList = Files.readAllLines(Paths.get(filePath + "/baseline.txt"), Charset.defaultCharset());

        List<String> exp = onlineList.stream().map(t -> t.substring(4))
                .map(t -> JSON.parseObject(t)).
                        map(t -> t.getString("exp")).
                        sorted().collect(Collectors.toList());


        List<String> baseLineList = baseList.stream().map(t -> t.substring(4))
                .map(t -> JSON.parseObject(t)).
                        map(t -> t.getString("exp")).
                        sorted().collect(Collectors.toList());

        List<String> collect = haveUserGetList.stream().map(t -> {
            String s = t.split(",")[0];
            return s.substring(1, s.length() - 1);
        }).sorted().collect(Collectors.toList());


        List<String> clone = ObjectUtils.clone(exp);


        for (String s : exp) {
            if(collect.contains(s)) {
                clone.remove(s);
            }else if(baseLineList.contains(s)){
                clone.remove(s);
            }
        }
        for (String s : clone) {
            System.out.println(s);
        }


    }

}
